﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

namespace ValidationFramework.Tests.Integration
{
	[TestFixture]
	public class InitializationTest
	{
		public class Car
        {
			public int DoorCount{get; set;}
			public string ModelName {get; set;}
        }
		[Test]
		public void Calling_Init_Should_Reset_Policies()
		{
			// Arrange
			Validation.Initialize();

			Assert.AreEqual(0, Validation.GetTypePolicyFor<Car>().RuleCount);

			Validation.ConfigurePolicyFor<Car>(x => 
			{
				x.Ensure(y => y.DoorCount)
					.Passes(new AlwaysFailValidator())
					.OnFailure()
						.UseMessage("Test");
			});

			Assert.AreEqual(1, Validation.GetTypePolicyFor<Car>().RuleCount);

			// Act
			Validation.Initialize();

			// Assert
			Assert.AreEqual(0, Validation.GetTypePolicyFor<Car>().RuleCount);
		}
	}
}
